// 配置路由
import JikeLayout from "@/pages/Layout";
import Login from "@/pages/Login";
import { createBrowserRouter } from "react-router-dom";
import { AuthRouter } from "@/components/authRouter";
// import Home from "@/pages/Home";
// import Article from "@/pages/Article";
// import Publish from "@/pages/Publish";
import { lazy, Suspense } from "react";

const Home = lazy(() => import('@/pages/Home'))
const Article = lazy(() => import('@/pages/Article'))
const Publish = lazy(() => import('@/pages/Publish'))

const router = createBrowserRouter([
  {
    path:'/',
    element:<AuthRouter>
        <JikeLayout/>
        {/* 提升到父组件，子组件无需重复包裹 */}
        <Suspense fallback={'加载中'}/>
      </AuthRouter>,
    children:[
      {
        index:true,
        element:<Home/>
      },
      {
        path:'article',
        element:<Article/>
      },
      {
        path:'publish',
        element:<Publish/>
      }
    ]
  },
  {
    path:'/login',
    element:<Login/>
  },

])

export default router